#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <ostream>
using namespace std;
class Date {
public:
    Date(int year = 1900, int month = 1, int day = 1)
        : _year(year)
        , _month(month)
        , _day(day)
    {
    }
    Date(const Date& d)
        : _year(d._year)
        , _month(d._month)
        , _day(d._day)
    {
    }
    Date& operator=(const Date& d) {
        _year = d._year;
        _month = d._month;
        _day = d._day;
        return *this;
    }
    Date& operator+=(int day) {
        if (day < 0)
        {
            return *this -= -day;
        }
        _day += day;
        while (GetDay(_month) < _day) {
            _day -= GetDay(_month);
            _month++;
            if (_month > 12)
                _month = 1;
        }
        return *this;
    }
    Date& operator-=(int day) {
        _day -= day;
        while (_day <= 0) {
            _month--;
            if (_month < 1)
                _month = 12;
            _day += GetDay(_month);
        }
        return *this;
    }
    Date operator+(int day) {
        Date tmp = *this;
        tmp += day;
        return tmp;
    }
    Date operator-(int day) {
        Date tmp = *this;
        tmp -= day;
        return tmp;
    }
    bool operator==(const Date& d) const
    {
        return  _year == d._year
            && _month == d._month
            && _day == d._day;
    }

    int GetDay(int month) {
        int days[13] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 3130, 31 };
        if (month == 2 && ((_year % 4 == 0 && _year % 100 != 0) || (_year % 400 == 0)))
            return 29;
        return days[month];
    }
    friend ostream& operator<<(ostream& out, const Date& d);
private:
    int _year;
    int _month;
    int _day;
};
ostream& operator<<(ostream& out, const Date& d)
{
    out << d._year << "-" << d._month << "-" << d._day << endl;
    return out;
}

int main() {
    Date d1(2020, 2, 20);
    d1 += -10;
    Date d2 = d1 + 100;
    cout << d1 << d2;
    cout << (d1 == d2);
    return 0;
}
